Framework
Physical object in the game world.
Entities are physical representations of objects in the game world. Lilia extends the functionality of entities to interface between Lilia's own classes and to reduce boilerplate code.
See the Garry's Mod Wiki for all other methods that the Player
class has.
Functions
entityMeta:assignCreator(client)
Assigns a creator to the entity.
Parameters
-
client
Player
The player to assign as the creator of the entity.
Example Usage
entity:assignCreator(player)
entityMeta:canSeeEntity(entity)
Checks if the entity can see another entity.
Parameters
-
entity
Entity
The entity to check visibility against.
Returns
-
Boolean
True if the entity can see the target entity, false otherwise.
Example Usage
if entity:canSeeEntity(targetEntity) then
print("Entity can see the target entity.")
else
print("Entity cannot see the target entity.")
end
entityMeta:clearNetVars(receiver)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Clears all of the networked variables.
Parameters
-
receiver
Player
The players to clear the networked variable for
Example Usage
entity:clearNetVars(player)
entityMeta:getEntItemDropPos()
Retrieves the drop position for an item associated with the entity.
Returns
-
Vector
The drop position for the item.
Example Usage
local dropPos = entity:getEntItemDropPos()
print("Item drop position:", dropPos)
entityMeta:getNetVar(key, default)
Retrieves a networked variable. If it is not set, it'll return the default that you've specified.
Parameters
-
key
String
Identifier of the networked variable
-
default
any
Default value to return if the networked variable is not set
Returns
-
any
The value associated with the key, or the default that was given if it doesn't exist
Example Usage
local example = entity:getNetVar("example", "Default Value")
print(example) -- Output: "Hello World!" or "Default Value"
See Also
entityMeta:getNetVar(key, default)
Retrieves the value of a networked variable associated with the entity.
Parameters
-
key
String
The identifier of the networked variable.
-
default
any
The default value to return if the networked variable does not exist.
Returns
-
any
The value of the networked variable, or the default value if it doesn't exist.
Example Usage
local example = entity:getNetVar("example", "Default Value")
print(example) -- Output: "Hello World!" or "Default Value"
entityMeta:getViewAngle(pos)
Gets the view angle between the entity and a specified position.
Parameters
-
pos
Vector
The position to calculate the view angle towards.
Returns
-
The
view angle in degrees.
Example Usage
local angle = entity:getViewAngle(targetPos)
print("View angle:", angle)
entityMeta:inFov(entity, fov)
Checks if the entity is within the field of view of another entity.
Parameters
-
entity
Entity
to check the field of view against.
-
fov
Float
The field of view angle in degrees.
Returns
-
Boolean
True if the entity is within the field of view, false otherwise.
Example Usage
if entity:inFov(playerEntity, 90) then
print("Entity is within the player's field of view.")
end
entityMeta:inTrace(entity)
Checks if the entity is in line of sight of another entity.
Parameters
-
entity
Entity
The entity to check line of sight against.
Returns
-
Boolean
True if the entity is in line of sight, false otherwise.
Example Usage
if entity:inTrace(targetEntity) then
print("Entity is in line of sight of the target.")
else
print("Entity is not in line of sight of the target.")
end
entityMeta:isChair()
Checks if the entity is a chair.
Returns
-
Boolean
True if the entity is a chair, false otherwise.
Example Usage
if entity:isChair() then
print("Entity is a chair.")
end
entityMeta:isInRoom(target)
Checks if the entity is inside a room (i.e., not blocked by world geometry) with another target entity.
Parameters
-
target
Entity
The target entity to check for room visibility.
Returns
-
Boolean
True if the entity is in the same room as the target entity, false otherwise.
Example Usage
if entity:isInRoom(targetEntity) then
print("Entities are in the same room.")
else
print("Entities are not in the same room.")
end
entityMeta:isItem()
Checks if the entity is an item entity.
Returns
-
Boolean
True if the entity is an item entity, false otherwise.
Example Usage
if entity:isItem() then
print("Entity is an item.")
end
entityMeta:isMoney()
Checks if the entity is a money entity.
Returns
-
Boolean
True if the entity is a money entity, false otherwise.
Example Usage
if entity:isMoney() then
print("Entity is money.")
end
entityMeta:isNearEntity(radius)
Checks if there is an entity near the current entity within a specified radius.
Parameters
-
radius
Float
The radius within which to check for nearby entities.
Returns
-
Boolean
True if there is an entity nearby, false otherwise.
Example Usage
if entity:isNearEntity(150) then
print("There is an entity nearby.")
else
print("No entities within the specified radius.")
end
entityMeta:isProp()
Checks if the entity is a physics prop.
Returns
-
Boolean
True if the entity is a physics prop, false otherwise.
Example Usage
if entity:isProp() then
print("Entity is a physics prop.")
else
print("Entity is not a physics prop.")
end
entityMeta:isScreenVisible(entity, maxDist, fov)
Checks if the entity has a clear line of sight to another entity and is within a specified distance and field of view angle.
Parameters
-
entity
Entity
The entity to check visibility against.
-
maxDist
Float
The maximum distance squared within which the entity can see the other entity.
-
fov
Float
The field of view angle in degrees.
Returns
-
Boolean
True if the entity has a clear line of sight to the other entity within the specified distance and field of view angle, false otherwise.
Example Usage
if entity:isScreenVisible(targetEntity, 300000, 90) then
print("Entity is visible on the screen.")
end
entityMeta:isSimfphysCar()
Checks if the entity is a simfphys car.
Returns
-
Boolean
True if the entity is a simfphys car, false otherwise.
Example Usage
if entity:isSimfphysCar() then
print("Entity is a simfphys car.")
end
entityMeta:sendNetVar(key, receiver)
This is an internal function! You are able to use it, but you risk unintended side effects if used incorrectly.
Sends a networked variable.
Parameters
-
key
String
Identifier of the networked variable
-
receiver
Player
The players to send the networked variable to
Example Usage
entity:sendNetVar("health", player)
entityMeta:setNetVar(key, value, receiver)
Sets the value of a networked variable.
Parameters
-
key
String
Identifier of the networked variable
-
value
any
New value to assign to the networked variable
-
receiver
Player
The players to send the networked variable to
Example Usage
entity:setNetVar("example", "Hello World!", player)